/**
 * 公共权限处理
 * @author nikolatesfei
 */

import Configs from 'admin/config/permissions/configs'
import Persons from 'admin/config/permissions/persons'
import Axios from 'admin/config/axios';

export const Permissions = Object.assign(Configs,Persons);
export function	Check(name,per){
	return new Promise((resolve, reject) => {
		Axios.Configs.Permission.User({name:name})
        .then(res=>{
        	if(!res) return false;
            var data = res.data;
            //超级管理员显示所有模块
            if(data['isMaster']!=undefined){
                for(var i in per){
                    per[i] = true;
                }
            }else{
                //获得的用户权限显示相应模块
                for(var i in data){
                    per[data[i].replace(/\//g,'_')] = true;
                }
            }
            resolve(per);
        })
	})
}


